/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package chatsoft.server.buz;

import ChatSoft.model.ChatMessage;
import ChatSoft.model.FileRequestMessage;
import ChatSoft.model.FileResponseMessage;
import ChatSoft.model.VoiceRequestMessage;
import ChatSoft.model.VoiceResponseMessage;
import ChatSoft.model.buz.SendObject;
import java.io.ObjectOutputStream;

/**
 *
 * @author KID
 */
public class ChatBussiness {

    private ObjectOutputStream outStreamRecieve;

    public ChatBussiness() {
    }

    public Boolean CheckChatRequest(String name) {
        if (ServerStaticVariable.userOnlineStream.containsKey(name)) {
            return true;
        }
        return false;
    }

    public void Chat(ChatMessage mess) {
        try {
            outStreamRecieve = ServerStaticVariable.userOnlineStream.get(mess.getSendTo());
            SendObject.sendObject(mess, outStreamRecieve);
        } 
        catch (Exception ex) {

        }
    }

    public void forwardVoiceRequest(VoiceRequestMessage request) {
        try {
            outStreamRecieve = ServerStaticVariable.userOnlineStream.get(request.getSendTo());
            SendObject.sendObject(request, outStreamRecieve);
        }
        catch (Exception ex) {

        }
    }
    
    public void forwardVoiceResponse(VoiceResponseMessage response) {
        try {
            outStreamRecieve = ServerStaticVariable.userOnlineStream.get(response.getSendTo());
            SendObject.sendObject(response, outStreamRecieve);
        }
        catch (Exception ex) {

        }
    }
    
    public void forwardFileRequest(FileRequestMessage request) {
        try {
            outStreamRecieve = ServerStaticVariable.userOnlineStream.get(request.getSendTo());
            SendObject.sendObject(request, outStreamRecieve);
        }
        catch (Exception ex) {

        }
    }
    
    public void forwardFileResponse(FileResponseMessage response) {
        try {
            outStreamRecieve = ServerStaticVariable.userOnlineStream.get(response.getSendTo());
            SendObject.sendObject(response, outStreamRecieve);
        }
        catch (Exception ex) {

        }
    }
}
